/*
 * MetricPlotter.java
 *
 * Created on June 26, 2007, 2:03 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.semanticvoid.lifelogger.metrics.plot;

import com.semanticvoid.lifelogger.db.DbInterface;

/**
 *
 * @author anand_kishore
 */
public class MetricPlotter {
    
    public static int getCountOfItemsInSystem(int type) {
        return DbInterface.getCountForItem(type);
    }
    
    public static String getTimeLineDistributionForPeriodAsJSString(int type, String from, String to) {
        if(from.equals("") || to.equals("")) {
            return "";
        }
        
        int[] timeLine = DbInterface.getTimelineDistribution(type, from, to);
        StringBuffer timeLineJS = new StringBuffer();
        
        for(int i=0; i<timeLine.length; i++) {
            timeLineJS.append("[" + i + ", " + timeLine[i] + "]");
            
            if(i != timeLine.length-1) {
                timeLineJS.append(",");
            } else {
                timeLineJS.append(", [ 24," + timeLine[0] + "]");
            }
        }
        
        return timeLineJS.toString();
    }
}
